import torch
import torchvision
from torch import nn
from torch.nn import MaxPool2d
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter

dataset = torchvision.datasets.CIFAR10(root='./dataset', train=False, download=True,
                                       transform=torchvision.transforms.ToTensor())
dataLoad = DataLoader(dataset, batch_size=64)


class Con_module(nn.Module):
    def __init__(self):
        super().__init__()
        self.maxpool1 = MaxPool2d(kernel_size=3, ceil_mode=False)

    def forward(self, input):
        output = self.maxpool1(input)
        return output

writer = SummaryWriter('logs_maxpool')
module = Con_module()
step = 0

for data in dataLoad:

    imgs, targets = data
    writer.add_images('input', imgs, step)
    output = module(imgs)
    writer.add_images('output', output, step)
    step += 1

writer.close()